<%@page import="com.lyb.bean.User"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>用户管理</title>
<style>
.header{
float:right;
font-size:16px;
}
table{
margin:10px 60px;
}
</style>
</head>
<body>
<div class="header"><a href="/zaixiantougao/index.jsp">退出登录</a></div>
<ul>

<li><a href="gaojianfenpei.jsp">稿件分配</a></li>
<li><a href="guanliyonghu.jsp">管理用户</a></li>
<li><a href="guanligaojian.jsp">管理稿件</a></li>

</ul>
<table>
<tr><td>用户名</td>
<td>密码</td>
<td>类型</td></tr>
<%
try {
			Class.forName("com.mysql.jdbc.Driver");
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String url = "jdbc:mysql://localhost:3306/tougaoxitong?useUnicode=true&characterEncoding=UTF-8";
		String user = "root";
		String mysqlpassword = "";
		
		
		Connection conn = DriverManager.getConnection(url,user,mysqlpassword);
		
			
//			查询
			Statement stmt = conn.createStatement();
			String sql = "select * from user";
			ResultSet rs = stmt.executeQuery(sql);
			ArrayList<User> userList =new ArrayList<User>(); 
			while(rs.next()){
				User user1 =new User();
				String username = rs.getString("username");
				String password = rs.getString("password");
				int type = rs.getInt("type");
				user1.setUsername(username);
				user1.setPassword(password);
				user1.setType(type);
				userList.add(user1);
			}
			for(int i=0;i<userList.size();i++){
				User user1 = userList.get(i);
%>

<tr>
<td><%=user1.getUsername() %></td>
<td><%=user1.getPassword() %></td>
<td><%=user1.getType() %></td>
<td><a href="xiugaiyonghu.jsp?username=<%= user1.getUsername() %>&&password=<%=user1.getPassword()%>&&type=<%=user1.getType()%>">修改</a></td>
<td><a href="deleteuser?username=<%= user1.getUsername()%>">删除</a></td>
</tr>
				
<%			}
%>
</table>
</body>
</html>